import { getAreaObj } from '@/utils/util'
import {cloneDeep} from 'lodash-es'
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '申请人',
			prop: 'applicantName',
		},
		{
			label: '申请人身份证',
			prop: 'applicantIdCard',
		},
		{
			label: '长者',
			prop: 'elderName',
		},
		{
			label: '长者身份证',
			prop: 'elderIdCard',
		},
		{
			label: '状态',
			prop: 'state',
		},
		{
			label: '备注',
			prop: 'remark',
		},
		{
			label: '提交时间',
			prop: 'submitTime',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

const searchConfig = {
	inline: true,
	column: [
		{
			label: '申请人',
			prop: 'applicantName',
			type: 'input',
			span: 8,
		},
		{
			label: '长者',
			prop: 'elderName',
			type: 'input',
			span: 8,
		},

		{
			label: '申请人身份证',
			prop: 'applicantIdCard',
			type: 'input',
			span: 8,
		},
		{
			label: '长者身份证',
			prop: 'elderIdCard',
			type: 'input',
			span: 8,
		},
		{
			label: '审核状态',
			prop: 'state',
			type: 'remoteSelect',
			code: 'EXAMINE_STATE',
			api: 'getDictItemList',
			span: 8,
		},
		{
			label: '提交时间',
			prop: 'submitTimeBetween',
			type: 'dateBetween',
			format: 'YYYY年MM月DD',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 12,
		},
	],
}
const detailConfig = {
	inline: false,
	labelPosition: 'left',
	labelWidth: '200px',
	showBtn: false,
	column: [
		{
			type: 'DividerHtml',
			labelPosition: 'top',
			position: 'center',
			modelValue: '申请人信息',
			span: 24,
		},
		{ label: '申请人', prop: 'applicantName', span: 8 },
		{ label: '身份证', prop: 'applicantIdCard', span: 8 },
		{ label: '手机号', prop: 'applicantPhone', span: 8 },
		{
			label: '性别',
			prop: 'aplicationGender',
			dicData: [
				{ label: '男', value: '1' },
				{ label: '女', value: '2' },
			],
			span: 8,
		},
		{ label: '现居地', prop: 'applicantAddress', span: 8 },
		{ label: '户籍地', prop: 'applicantCrAddress', span: 8 },
		{
			type: 'DividerHtml',
			labelPosition: 'top',
			position: 'center',
			modelValue: '长者信息',
			span: 24,
		},
		{ label: '姓名', prop: 'elderName', span: 8 },
		{ label: '身份证', prop: 'elderIdCard', span: 8 },
		{ label: '手机号', prop: 'elderPhone', span: 8 },
		{
			label: '性别',
			prop: 'elderGender',
			dicData: [
				{ label: '男', value: '1' },
				{ label: '女', value: '2' },
			],
			span: 8,
		},
		{ label: '现居地', prop: 'residence', span: 8 },
		{ label: '户籍地', prop: 'crResidence', span: 8 },
		{
			label: '附件',
			prop: 'facePhoto',
			type: 'upload',
			span: 24,
		},
	],
}
export const baseConfig: any = {
	pageName: '用户绑定长者管理',
	addLabel: '',
	dictcodes: ['EXAMINE_STATE'],
	rowKey: 'id',
	tipLabel: 'applicantName',
	api: {
		index: 'view_bscKinshipApply_page',
		detail: 'view_bscKinshipApply_view',
		// add: 'view_ofsSubsidyApply_add',
		// export: 'view_ofsSubsidyApply_approval_exportApply'
		// 	edit: 'view_ofsSubsidyProject_edit',
		// 	delete: 'view_ofsSubsidyProject_del',
	},
	auth: {
		index: 'view_bscKinshipApply_page',
		detail: 'view_bscKinshipApply_view',
		// add: 'view_ofsSubsidyApply_add',
		// mulitSet: 'view_ofsSubsidyApply_approval_exportApply'
		// 	edit: 'view_ofsSubsidyProject_edit',
		// 	delete: 'view_ofsSubsidyProject_del',
	},

	menuBtn: [
		{
			icon: '',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: 'view_ofsSubsidyApply_view',
			text: true,
			show: true,
		},
	],
	// operateFormate: async (form, type) => {
	// 	let item = cloneDeep(form)
	// 	const areasInfo: any = getAreaObj(item, 'cr')
	// 	const crAreasInfo: any = getAreaObj(item, '')
	// 	return Promise.resolve({
	// 		...item,
	// 		areas: areasInfo.areaIds,
	// 		areasName: areasInfo.names,
	// 	})
	// },
	beforeOnLoadFormate: async (query) => {
		return new Promise((resolve, reject) => {
			const crAreasObj: any = getAreaObj(query.authAreas, '')
			resolve({
				...query,
				...crAreasObj,
				authAreas: undefined,
			})
		})
	},
	searchConfig,
	tableConfig,
	detailConfig,
}
